package io.afu.baseframework.controller;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.afu.baseframework.constants.CommonConst;
import io.afu.baseframework.dto.resp.CheckAliveResp;

@RestController
public class CheckAliveController {

    @Value("${spring.application.name:baswformework}")
    private String instanceName;

    @Value("${app.profile:unknown}")
    private String profile;

    @Value("${app.version:0.1}")
    private String version;
    

    @RequestMapping("/check/alive")
    public CheckAliveResp checkAlive() {
        CheckAliveResp checkAliveResp = new CheckAliveResp();
        checkAliveResp.setInstantceName(instanceName);
        checkAliveResp.setCheckTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern(CommonConst.COMMON_TIME_FORMAT)));
        checkAliveResp.setProfile(profile);
        checkAliveResp.setAlive(true);
        checkAliveResp.setVersion(version);
        return checkAliveResp;
    }




}